package com.neusoft.weekreport.component.controller;

import com.neusoft.weekreport.component.bizService.impl.ExportExcelService;
import com.neusoft.weekreport.component.bizService.impl.ExportMonthExcelService;
import com.neusoft.weekreport.component.req.ExportWeekInfoReq;
import com.neusoft.weekreport.component.req.GetExportExcelReq;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

@RestController
@EnableTransactionManagement
@RequestMapping("/exportExcel")
public class ExportExcelController {
    Logger logger = LoggerFactory.getLogger(this.getClass());

    @Resource
    ExportExcelService exportExcelService;

    @Resource
    ExportMonthExcelService exportMonthExcelService;

    //按天导出日报到excel
    @RequestMapping(value="/exportDayInfo",method = RequestMethod.POST)
    public void exportWeekInfo(@RequestBody GetExportExcelReq req, HttpServletResponse response){
        try{
            exportExcelService.exportDayInfo(req,response);
        }catch (Exception e){
            logger.error(e.toString());
        }
    }

    //按月导出日报到excel
    @RequestMapping(value="/exportMonthInfo",method = RequestMethod.POST)
    public void exportMonthInfo(@RequestBody GetExportExcelReq req, HttpServletResponse response){
        try{
            exportMonthExcelService.exportMonthInfo(req,response);
        }catch (Exception e){
            logger.error(e.toString());
        }
    }
}
